local skel = fk.CreateSkill {
  name = "lb_zero__guibu",
}

Fk:loadTranslationTable {
  ["lb_zero__guibu"] = "诡步",
  [":lb_zero__guibu"] = "当你使用基本牌后，你可以弃置一名角色的一张牌，然后其可对你使用一张【杀】。 ",

  ["#lb_zero__guibu"] = "诡步：你可以弃置一名角色的一张牌，然后其可对你使用一张【杀】",
  ["#lb_zero__guibu_dis"] = "诡步：弃置 %src 一张牌",
  ["#lb_zero__guibu_use"] = "诡步：你可以对 %src 使用一张【杀】",

  ["$lb_zero__guibu1"] = "别想逃。",
  ["$lb_zero__guibu2"] = "该我啦！",
  ["$lb_zero__guibu3"] = "注意后背。",
}


skel:addEffect(fk.CardUseFinished, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and data.card.type == Card.TypeBasic and
        table.find(player.room.alive_players, function(to)
          return not to:isNude()
        end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = table.filter(room:getAlivePlayers(), function(to)
      return not to:isNude()
    end)
    if #tos == 0 then return end
    tos = room:askToChoosePlayers(target, {
      targets = tos,
      min_num = 1,
      max_num = 1,
      skill_name = skel.name,
      prompt = "#lb_zero__guibu",
      cancelable = true,
    })
    if #tos > 0 then
      event:setCostData(self, { tos = tos })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local cid = room:askToChooseCard(target, {
      target = to,
      flag = "he",
      skill_name = skel.name,
      prompt = "#lb_zero__guibu_dis:" .. to.id,
    })
    if cid then
      room:throwCard(cid, skel.name, to, player)
    end
    if to:isAlive() and player:isAlive() and to:canUseTo(Fk:cloneCard("slash"), player, {bypass_times = true}) then
      local use = room:askToUseCard(to, {
        skill_name = skel.name,
        pattern = "slash",
        prompt = "#lb_zero__guibu_use:" .. player.id,
        cancelable = true,
        extra_data = {must_targets = {player.id}, bypass_times = true},
      })
      if use then
        use.extraUse = true
        room:useCard(use)
      end
    end
  end,
})

return skel
